<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>流程代办人</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body>
        <form id="flow_agent_usr_form">
        	<!-- 传递选择的人员ID -->
            <div class="fieldset1 tabel_col tabel_col_s clearFix noBorder">
                <div class="fieldBox col_50">
                    <div class="label">流程定义</div>
                    <div class="field">
                        <select name="procDefKey" id="procDefKey" data-value="" validate="{required:true, select: true}">
			            	<c:forEach items="${searchSelectProcDefNameList }" var="kv" begin="0" step="1" varStatus="status">
								<c:if test="${status.index == 0}">
								     <option value="${kv.key }" checked >${kv.value }</option>
								</c:if>
							<c:if test="${status.index != 0}">
								    <option value="${kv.key }">${kv.value }</option>
								</c:if>
							</c:forEach>
			            </select>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">代办人</div>
                    <div class="field">
                        <input name="agentUsrNm" id="agentUsrNm" type="text" class="ui-textbox" value="" validate="{required:true,maxlength:20}">
                        <span class="requiredSymbol">*</span>
                        <input name="agentUsrId" id="agentUsrId" type="text" hidden="true" value=""/>
                    </div>
                </div>
                <div class="fieldBox col_50">
			         <div class="label">开始日期</div>
			            <div class="field">
			               <input name="startTm" id="startTm" type="text" class="ui-datepicker" value="" validate="{required:true}">
			            <span class="requiredSymbol">*</span>
			         </div>
			    </div>
			    <div class="fieldBox col_50">
			         <div class="label">结束日期</div>
			            <div class="field">
			               <input name="endTm" id="endTm" type="text" class="ui-datepicker" value="" validate="{required:true}">
			            <span class="requiredSymbol">*</span>
			         </div>
			    </div>
            </div>
            <div class="btnsBox">
                <span id="flow_agent_usr_form_add_btn_id" class="sq-button sq-button-round"></i>保存</span>
                <span id="flow_agent_usr_form_cancel_btn_id" class="sq-button sq-button-round">取消</span>
            </div>
        </form>
	<script>
		$(function() {
			$("#startTm").ligerDateEditor({ showTime: true, width:"180", format:"yyyy-MM-dd hh:mm:ss"});
			$("#endTm").ligerDateEditor({ showTime: true, width:"180", format:"yyyy-MM-dd hh:mm:ss"});
			
		   $("#flow_agent_usr_form").ligerForm({
                validate: true
           });
		   
		   //代办人录入框点击后显示选人窗口
		   $("#agentUsrNm").focus(function(event) {
		        if(frameElement && frameElement.dialog) {
		            var dialog_data=frameElement.dialog.get("_data");
		            dialog_data.openDialogForChooseUsr();
		        }
		    });
		
		   
	        $("#flow_agent_usr_form_add_btn_id").click(function(event) {
	            var ligerForm = liger.get("flow_agent_usr_form");
	            if (!ligerForm.valid()) {
	                top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO,SQ_type: "warning"});
	                return false; //验证不通过，不执行以下代码
	            }
	            var data = ligerForm.getData();
	            //开始时间
	            data["startTm"] = $("#startTm").val();
	            //结束时间
	            data["endTm"] = $("#endTm").val();
	            var url = '<%=path%>/flow/flow/addFlowAgentUsr.do';
	            
	            AjaxUtils.ajaxPost(url, data, function(msg){
	            	if(msg.success == 1){
	            		 UIUtils.alertSuccess(msg.info);
	       				 parent.grid.reload();
	       				 frameElement.dialog.close();
	       			 }else{
	       				 UIUtils.alertError(msg.info);
	       			 }
	            },true);
	        });
	        
	        //取消
	        $("#flow_agent_usr_form_cancel_btn_id").click(function(event) {
	        	frameElement.dialog.close();
	        });
		});
		
		if(frameElement && frameElement.dialog) {
		    frameElement.dialog.set("_subWin", this); //把这个窗口对象绑到父窗口的dialog对象上
		};
	</script>
</body>
</html>